package cn.finyzq.ss.games.web.interceptor;


import cn.finyzq.ss.games.annotation.Public;
import com.alibaba.fastjson.JSONObject;
import org.springframework.core.annotation.AnnotationUtils;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.HandlerInterceptor;


import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

public abstract class AbstractInterceptor  implements HandlerInterceptor {

    boolean isPublic(HandlerMethod handlerMethod) {
        if(handlerMethod == null) {
            return false;
        } else {
            Public pp = handlerMethod.getMethodAnnotation(Public.class);
            if(pp != null) {
                return true;
            } else {
                Class<?> clazz = handlerMethod.getMethod().getDeclaringClass();
                pp = AnnotationUtils.findAnnotation(clazz, Public.class);
                return pp != null;
            }
        }
    }





}
